package com.jade.shoesmallinterface.mapper;

import com.jade.shoesmallinterface.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    // 查询所有用户信息
    @Select("SELECT * FROM USER")
    List<User> selectAllUsers();

    // 插入用户信息
    @Insert("INSERT INTO USER (username, PASSWORD, email, create_time, update_time) VALUES (#{username}, #{password}, #{email}, NOW(), NOW())")
    int insertUserInfo(User user);

    // 删除用户信息
    @Delete("DELETE FROM USER WHERE username = #{username}")
    int deleteUserByName(String username);

    // 更新用户信息
    @Update("UPDATE USER SET username = #{username}, PASSWORD = #{password},email=#{email},avatar_url=#{avatarUrl},address=#{address},birthDate=#{birthDate},gender=#{gender},phone=#{phone},update_time = NOW() WHERE user_id = #{userid}")
    int updateUserInfo(User user);

    // 根据用户邮箱号查询用户信息
    @Select("SELECT * FROM USER WHERE email = #{email}")
    User selectUserInfoByEmail(String email);
}
